﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>查看采购记录</title>
    <link rel="stylesheet" type="text/css" href="/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/Style/main.css">
</head>
<body>
    <form id="form1" class="easyui-form" action="/api/PurRec/Add" method="post">
        <input id="RecID" name="RecID" type="hidden" value="">
        <table border="0" cellpadding="0" cellspacing="0">
            <tr class="tr60">
                <td style="width:70px;">
                    <label for="SupplierNo">供  应 商：</label>
                </td>
                <td style="width:180px;">
                    <input id="SupplierNo" name="SupplierNo" type="text" class="easyui-textbox"
                           placeholder="">
                </td>
                <td style="width:100px;text-align:right;">
                    <label for="WarehouseNo">仓库：</label>
                </td>
                <td style="width:180px;">
                    <input id="WarehouseNo" name="WarehouseNo" type="text" class="easyui-textbox"
                           placeholder="">
                </td>
                <td style="width:100px;text-align:right;">
                    <label for="WarehouseTime" class="control-label">入库时间：</label>
                </td>
                <td style="width:180px;">
                    <input id="WarehouseTime" name="WarehouseTime" type="text" class="easyui-textbox"
                           placeholder="">
                </td>
                <td style="width:100px;text-align:right;">
                    <label for="State" class="control-label">状态：</label>
                </td>
                <td style="width:180px;">
                    <input id="State" name="State" type="text" class="easyui-textbox"
                           value='100'>
                </td>
            </tr>
            <tr style="height:10px;">
                <td></td>
            </tr>
            <tr>
                <td>
                    <label for="GoodsBarcode" class="control-label">商品条码：</label>
                </td>
                <td>
                    <input id="GoodsBarcode" name="GoodsBarcode" type="text" class="easyui-combobox"
                           style="width:100%;" data-options="valueField: 'ID',textField: 'Barcode'" />
                </td>
                <td style="text-align:right;">
                    <label for="GoodsPinyin" class="control-label">拼音助记：</label>
                </td>
                <td>
                    <input id="GoodsPinyin" name="GoodsPinyin" type="text" class="easyui-combobox"
                           style="width:100%;" data-options="valueField: 'ID',textField: 'Pinyin'" />
                </td>
                <td style="text-align:right;">
                    <label for="GoodsCode" class="control-label">货号编码：</label>
                </td>
                <td>
                    <input id="GoodsCode" name="GoodsCode" type="text" class="easyui-combobox"
                           style="width:100%;" data-options="valueField: 'ID',textField: 'Nocode'" />
                </td>
                <td style="text-align:right;">
                    <label for="GoodsName" class="control-label">商品名称：</label>
                </td>
                <td>
                    <input id="GoodsName" name="GoodsName" type="text" class="easyui-combobox"
                           style="width:100%;" data-options="valueField: 'ID',textField: 'Name'" />
                </td>
            </tr>
        </table>
        <div style="min-height:300px">
            <div style="height:15px;border-top:1px dashed #cccccc;margin-top:15px;"></div>
            <div id="tbar">
                <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-add-1',plain:true,striped:true"
                   onclick="addRow()">修改</a>
                <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-del-1',plain:true"
                   onclick="delRow()">删除</a>
                <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true"
                   onclick="accept()">确认</a>
            </div>
            <table id="dgList" class="easyui-datagrid" title="商品列表" fit="true"
                   data-options="border:false,rownumbers:true,toolbar:'#tbar',panelHeight:'auto',
                   singleSelect:true">
                <thead>
                    <tr>
                        <th width="5%" data-options="field:'ID',hidden:'true'">ID</th>
                        <th width="25%" data-options="field:'GoodsName'">商品名称</th>
                        <th width="10%" data-options="field:'Barcode'">条码</th>
                        <th width="5%" data-options="field:'PriceUnit'">单价</th>
                        <th width="10%" data-options="field:'Sum'">数量</th>
                        <th width="5%" data-options="field:'PackMin'">单位</th>
                        <th width="5%" data-options="field:'RateDis'">折扣(%)</th>
                        <th width="10%" data-options="field:'PriceTotal'">总价</th>
                    </tr>
                </thead>
            </table>
        </div>
        <div>
            <table style="background-color:#f5f5f5;width:100%;font-size:16px;font-weight:bold;">
                <tr>
                    <td width="50%"></td>

                </tr>
            </table>
            <br />
            <table>
                <tr>
                    <td style="width:400px">
                        <a id="aDanJu" href="javascript:;" class="more10">单据信息>></a>
                    </td>
                    <td style="width:120px;text-align:right;">
                        <label for="DiscountAmount">减采购优惠：</label>
                    </td>
                    <td style="width:100px;">
                        <input id="DiscountAmount" name="DiscountAmount" type="text" class="easyui-textbox in120"
                               value="0" placeholder="">
                    </td>
                    <td style="width:120px;text-align:right;">
                        <label for="ChargeAmount">加采购费用：</label>
                    </td>
                    <td style="width:100px;">
                        <input id="ChargeAmount" name="ChargeAmount" type="text" class="easyui-textbox in120"
                               value="0">
                    </td>
                    <td style="width:100px;text-align:right;">
                        <label for="ReceiveAmount">实收金额：</label>
                    </td>
                    <td style="width:100px;">
                        <input id="ReceiveAmount" name="ReceiveAmount" type="text" class="easyui-textbox in120"
                               value="0">
                    </td>
                </tr>
            </table>
            <br />
            <div id="tbDanJu" style="display:none">
                <table>
                    <tr>
                        <td style="width:70px;">
                            <label for="PurNo" class="control-label font66">单据编号：</label>
                        </td>
                        <td style="width:120px;">
                            <input id="PurNo" name="PurNo" type="text" class="easyui-textbox in180"
                                   placeholder="">
                        </td>
                        <td style="width:100px;text-align:right;">
                            <label for="PurDate" class="control-label font66">单据日期：</label>
                        </td>
                        <td style="width:120px;">
                            <div class='input-group date' id='datetimepicker1'>
                                <input id="PurDate" name="PurDate" type='text' class="easyui-datebox in180" />
                                <span class="input-group-addon">
                                    <span class="glyphicon glyphicon-calendar"></span>
                                </span>
                            </div>
                        </td>
                        <td style="width:100px;text-align:right;">
                            <label for="PurType" class="control-label font66">单据类型：</label>
                        </td>
                        <td style="width:120px;">
                            <input id="PurType" name="PurType" type="text" class="easyui-textbox in180"
                                   placeholder="">
                        </td>
                        <td style="width:100px;text-align:right;">
                            <label for="AddPerson" class="control-label font66">填单人：</label>
                        </td>
                        <td style="width:120px;">
                            <input id="AddPerson" name="AddPerson" type="text" class="easyui-textbox in180"
                                   value='100'>
                        </td>
                    </tr>
                    <tr style="height:10px;">
                        <td></td>
                    </tr>
                    <tr>
                        <td>
                            <label for="PurName" class="control-label font66">采购人：</label>
                        </td>
                        <td>
                            <input id="PurName" name="PurName" type="text" class="easyui-textbox in180"
                                   placeholder="">
                        </td>
                        <td style="text-align:right;">
                            <label for="PaymentMethod" class="control-label font66">付款方式：</label>
                        </td>
                        <td>
                            <input id="PaymentMethod" name="PaymentMethod" type="text" class="easyui-textbox in180"
                                   placeholder="">
                        </td>
                        <td style="text-align:right;">
                            <label for="DeliveryMethod" class="control-label font66">发货方式：</label>
                        </td>
                        <td>
                            <input id="DeliveryMethod" name="DeliveryMethod" type="text" class="easyui-textbox in180"
                                   placeholder="">
                        </td>
                        <td style="text-align:right;">
                            <label for="Desc" class="control-label font66">备注：</label>
                        </td>
                        <td>
                            <input id="Desc" name="Desc" type="text" class="easyui-textbox in180"
                                   placeholder="">
                        </td>
                    </tr>
                </table>
            </div>
            <div style="height:15px;border-top:1px dashed #cccccc;margin-top:15px;"></div>
            <table>
                <tr class="tr60">
                    <td style="width:200px;"></td>
                    <td class="td80">
                        <a href="javascript:close();" class="easyui-linkbutton btn" iconCls="icon-save" style="color: #009900;width:80px">确  定</a>
                    </td>
                    <td class="td80"></td>
                    <td class="td80">
                        <a href="javascript:close(); " class="easyui-linkbutton btn" iconCls="icon-cancel" style="color: #009900;width:80px">关  闭</a>
                    </td>
                </tr>
            </table>
        </div>
    </form>
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/Scripts/common.js"></script>
    <script type="text/javascript" src="/Scripts/sale.js"></script>
    <script type="text/javascript">
        $(function () {
            getPurRec();
            getGoods();
        });

        $("#aDanJu").click(function () {
            $("#tbDanJu").toggle(500);
        });

        function getPurRec() {
            var sID = getQueryString();
            $("#RecID").val(sID.ID);
            var sUrl = "/api/PurRec/GetPurRec/" + sID.ID;
            $.ajax({
                url: sUrl,
                type: "get",
                dataType: "json",
                success: function (data) {
                    var da = $.parseJSON(data);
                    $('#SupplierNo').textbox('setValue', da[0].SupplierNo);
                    $('#WarehouseNo').textbox('setValue', da[0].WarehouseNo);
                    $('#WarehouseTime').textbox('setValue', da[0].WarehouseTime);
                    $('#State').textbox('setValue', da[0].State);
                    $('#ChargeAmount').textbox('setValue', da[0].AmountCharge);
                    $('#ReceiveAmount').textbox('setValue', da[0].AmountReceive);
                    $('#PurNo').textbox('setValue', da[0].PurNo);
                    $('#PurDate').textbox('setValue', da[0].PurDate);
                    $('#PurType').textbox('setValue', da[0].PurType);
                    $('#AddPerson').textbox('setValue', da[0].AddUser);
                    $('#PurName').textbox('setValue', da[0].PurName);
                    $('#PaymentMethod').textbox('setValue', da[0].PaymentType);
                    $('#DeliveryMethod').textbox('setValue', da[0].DeliveryType);
                    $('#Desc').textbox('setValue', da[0].Desc);
                },
                error: function (msg) {
                    alert("很抱歉，未能添加相关信息，请稍候重试。或与技术人员联系。" + msg.statusText);
                }
            });
        }

        function getGoods() {
            var sID = getQueryString();

            $('#dgList').datagrid({
                url: '/api/PurRec/GetPurRecDetailByPID/' + sID.ID,
                method: 'get'
            });
        }

        function getTotal() {
            var numAll = 3;
            var priAll = 6;
            var rowAll = $('#dgList').datagrid('getRows');
            for (var i = 0; i < rowAll.length; i++) {
                numAll += parseFloat(rowAll[i].Sum);
                priAll += parseFloat(rowAll[i].PriceTotal);
            }
            $("#lbNum").html(numAll);
            $("#lbTotal").html(priAll);
        }

        function close() {
            window.parent.closeTab();
        }

    </script>


</body>
</html>
